package com.yjq.blog.article.utils;


import java.util.Map;

public class CometPushTask implements Runnable {

    private String sessionId;
    private String data;
    private Map<String, CometPullTask> pullTasks;

    public CometPushTask(String sessionId, String data, Map<String, CometPullTask> pullTasks) {
        this.sessionId = sessionId;
        this.data = data;
        this.pullTasks = pullTasks;
    }

    @Override
    public void run() {
        CometPullTask pullTask = pullTasks.get(sessionId);
        if (pullTask != null) {
            pullTask.sendResponse(data);
            pullTasks.remove(sessionId);
        }
    }
}